package com.huawei.appgallery.forum.forum.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import com.huawei.appgallery.forum.base.card.bean.BannerItem;
import o.azb;
import o.bun.c;
import o.bun.d;
import o.bun.e;
import o.bvb;
import o.dgh;
import o.dof;
import o.eqx;

public class ForumBanner extends FrameLayout {
    private String ˊ;
    private Context ˋ;
    ImageView ˎ;
    View ˏ;
    ImageView ॱ;

    public ForumBanner(Context context) {
        super(context);
        this.ˋ = context;
    }

    public ForumBanner(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.ˋ = context;
    }

    public void ˋ(ViewGroup viewGroup) {
        this.ˏ = LayoutInflater.from(this.ˋ).inflate(d.ˏ, viewGroup);
        this.ˎ = (ImageView) this.ˏ.findViewById(c.ʻ);
        this.ॱ = (ImageView) this.ˏ.findViewById(c.ॱˊ);
        int ˏ = bvb.ˏ(this.ˋ);
        ˏ = (((azb.ॱ(this.ˋ) - azb.ˊ(this.ˋ)) - azb.ˏ(this.ˋ)) - ((ˏ - 1) * this.ˋ.getResources().getDimensionPixelSize(e.ˎ))) / ˏ;
        int i = (int) (((double) ˏ) / 1.7080291970802919d);
        int dimensionPixelSize = this.ˋ.getResources().getDimensionPixelSize(e.ˏ) + i;
        LayoutParams layoutParams = new RelativeLayout.LayoutParams(ˏ, i);
        layoutParams.topMargin = this.ˋ.getResources().getDimensionPixelSize(e.ˏ);
        this.ॱ.setLayoutParams(layoutParams);
        this.ˎ.setLayoutParams(new RelativeLayout.LayoutParams(ˏ, dimensionPixelSize));
        this.ˏ.setLayoutParams(new LinearLayout.LayoutParams(ˏ, dimensionPixelSize));
    }

    public void setData(BannerItem bannerItem) {
        this.ˊ = bannerItem.ˏ();
        eqx.ˏ(this.ॱ, bannerItem.ˋ(), "image_default_icon");
        if (dof.ˋ(bannerItem.ˊ())) {
            this.ˎ.setVisibility(4);
            return;
        }
        eqx.ˏ(this.ˎ, bannerItem.ˊ(), "iconflag");
        this.ˎ.setVisibility(0);
    }

    public void ˊ() {
        dgh.ॱ(this.ˋ, "01240206", "01|" + this.ˊ);
    }
}
